package com.ten.shou.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ten.common.core.entity.HeadNav;
import com.ten.common.core.vo.Result;
import com.ten.shou.service.HeadService;
import com.ten.shou.vo.HeadVo;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author ：杨（1964958771@qq.com）
 * @date ：Created in 2022/12/5 20:37
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("home/head")
@Api(tags = "头部接口")
public class HeadController {
    @Resource
    private HeadService headService;
    @ApiOperation(value = "根分页查询头部信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "current",value = "当前页码"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示的条数")
    })
    @PostMapping("getAllHeadNav/{current}/{pageSize}")
    public Result<IPage<HeadNav>> getAllHeadNav(@PathVariable(required = true) Integer current, @PathVariable(required = true) Integer pageSize, @RequestBody HeadVo headVo) {
        return headService.getAllHeadNav(current,pageSize,headVo);
    }
    @PostMapping("addHeadNav")
    public Result addHeadNav(@RequestBody HeadNav headNav){
        return headService.insertAll(headNav);
    }
    @PostMapping("deleteHeadNav")
    public Result deleteHeadNav(@RequestBody HeadVo headVo){
        return headService.deleteById(headVo);
    }
    @PostMapping("changeStatus/{headId}/{isDiable}")
    public Result<HeadNav> changeStatus(@PathVariable String headId,@PathVariable String isDiable){
     return headService.updateStatusHead(headId,isDiable);
    }
    @PostMapping("updateHeadNav")
    public Result<HeadNav> updateHeadNav(@RequestBody HeadNav headNav){
        return headService.updateOperate(headNav);
    }
}
